#pragma once
#include <vector>
#include "afxcmn.h"
#include <map>

class CGTDListCtrl;

class ListCtrlItemImpl
{
public:
	virtual ~ListCtrlItemImpl(){}
	virtual void OnDoneEdit(CGTDListCtrl& ctrl, int index, int column ){ }	
	virtual void DblClickItem(CGTDListCtrl& ctrl, int index, int column){}
	virtual void OnSetToCtrl(CGTDListCtrl& ctrl){}
	virtual void OnChar(CGTDListCtrl& ctrl,UINT nChar, UINT nRepCnt, UINT nFlags){  }
protected:
	static CEdit* ShowInPlaceEdit(CGTDListCtrl& ctrl, int index, int column,const CString& s );
	static CComboBox* ShowInPlaceList( CGTDListCtrl& ctrl,int nItem, int nCol ,const CStringList& strlist);
};







typedef std::vector<int> IntList;

class CGTDListCtrl : public CListCtrl
{
public:	
	afx_msg BOOL OnEndlabeledit(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg BOOL OnClickColumn(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
	//void SetItemImpl(int nItem, int nSubItem, ListCtrlItemImpl* ,bool bManageDel = true);
	//ListCtrlItemImpl* GetItemImpl(int nItem, int nSubItem)const;

	int GetSelectedItems(IntList& itemlist)const;
	void SelectItem(int nItem);
	void UnSelectItem();
	bool GetCurSelect(int& index)const;

	//return result count, only add item,no remove 
	int EnLargeItemCount(int nCount);
	
	void setImpl(ListCtrlItemImpl* pImpl);
	ListCtrlItemImpl* getImpl()const{ return mpEditImpl; }

	CGTDListCtrl();
	virtual ~CGTDListCtrl();

	void InitStyle();
	
	//void ClearMangerList();
	virtual BOOL PreTranslateMessage(MSG* pMsg);

protected:
	ListCtrlItemImpl* mpEditImpl;
	//ListCtrlItemImpl* m_pLastEditImpl;	
	/*typedef std::map<int, ListCtrlItemImpl*> ItemImplMap;	
	ItemImplMap* GetImplMap(int nItem);
	ItemImplMap* GetImplMap(int nItem)const;
	void Clear();*/
		
	//std::vector<ItemImplMap*> m_vItemMapList; 
	//std::vector<ListCtrlItemImpl*> m_vManageImpList;
	//void AddManageImp(ListCtrlItemImpl* pImpl);

	// HitTestEx - Determine the row index and column index for a point
	// Returns   - the row index or -1 if point is not over a row
	// point     - point to be tested.
	// col       - to hold the column index
	int HitTestEx(CPoint& point, int* col);
	
	
	DECLARE_MESSAGE_MAP()


};

